from collections import deque
from time import sleep

NUM_LINES = 5
with open("test.file") as f:
    content = ''.join(deque(f, NUM_LINES))
    print(content)
    while True:
        content = f.read()
        if content:
            print(content)
        else:
            sleep(1)
